home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Science⁄Math / VideoToolbox / VideoToolboxSources / CenterRectInRect.c < prev    next >
Text File  |  1993-02-20  |  835b  |  33 lines

  1. /*
  2. CenterRectInRect.c
  3. ©1991-1993 Denis G. Pelli
  4. These routines are trivial, but enhance the readability of programs that use them.
  5.  
  6. HISTORY:
  7. 8/24/91    dgp    Made compatible with THINK C 5.0.
  8. 1/25/93 dgp removed obsolete support for THINK C 4.
  9. */
  10. #include "VideoToolbox.h"
  11.  
  12. void CenterRectInRect(Rect *a,Rect *b)
  13. {
  14.     OffsetRect(a,(b->left + b->right - a->left - a->right)/2
  15.         ,(b->top + b->bottom - a->top - a->bottom)/2);
  16. }
  17.  
  18. void OffsetRectTile(Rect *r,int nx,int ny) /* shift rect by multiples of the rect */
  19. // Shift rect by multiples of the rect
  20. {
  21.     OffsetRect(r,nx*(r->right-r->left),ny*(r->bottom-r->top));
  22. }
  23.  
  24. Boolean RectInRect(Rect *r,Rect *R)
  25. // Is the first rect entirely inside the second?
  26. // If either rect has zero area then this routine will return false.
  27. {
  28.     Rect t;
  29.     
  30.     if(!SectRect(r,R,&t))return 0;
  31.     return EqualRect(r,&t);
  32. }
  33.